﻿using BaiTu.IOCServices;
using System;
using System.Collections.Generic;

using System.Text;
using Autofac;
using BaiTu.Framework.Enums;
using BaiTu.IQueueService.Providers;

namespace BaiTu.QueueService
{
    public class Dependency : IDependencyRegistrater
    {
        public void Register(ContainerBuilder builder, BaiTu.Framework.Core.TypeFinder.ITypeFinder typeFinder)
        {
            switch (QueueConfiguration.QueueType)
            {
                case QueueType.MSMQ:
                    //ObjectFactory.Register<IQueueProvider, MSMQProvider>();
                    builder.RegisterType<Providers.MSMQProvider>().As<IQueueService.Providers.IQueueProvider>();
                    break;
                case QueueType.Redis:
                    //ObjectFactory.Register<IQueueProvider, RedisProvider>();
                    builder.RegisterType<Providers.RedisProvider>().As<IQueueService.Providers.IQueueProvider>();
                    break;
                case QueueType.RabbitMQ:
                    //ObjectFactory.Register<IQueueProvider, RabbitMQProvider>();
                    builder.RegisterType<Providers.RabbitMQProvider>().As<IQueueService.Providers.IQueueProvider>();
                    //启动后台监听线程

                    break;
            }
            builder.RegisterType<QueueService>().As<IQueueService.IQueue>();
            //ObjectFactory.Register<IQueue, QueueService>();            
        }

        public int Order
        {
            get { return 200; }
        }
    }
}
